package com.itqf.controller;

import com.itqf.entity.TbItem;
import com.itqf.service.TbItemService;
import com.itqf.service.impl.TbItemServiceImpl;
import com.itqf.utils.R;
import org.apache.log4j.Logger;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @Description:
 * @Company: 千锋互联
 * @Author: 李丽婷
 * @Date: 2021/1/25
 * @Time: 下午2:42
 */
@RestController
public class MyLayUiController {
    private Logger logger = Logger.getLogger(TbItemServiceImpl.class);

    @Resource
    private TbItemService tbItemService;

    @RequestMapping("/findItemByPage")
    //http://localhost:8080/findItemByPage?page=1&limit=10
    public R findItemByPage(int page, int limit){
        logger.warn("【查询]page:"+page+"--limit"+limit);
        return  tbItemService.findByPage(page,limit);
    }


    @RequestMapping("/delTbItem/{id}")
    public  R del(@PathVariable long id){

        return  tbItemService.del(id);
    }


    @RequestMapping("/updateTbItem")
    //1,表单或者地址栏上参数： (TbItem tbItem)
    //update?title=aa&id=111&sellPoint=sss

    //2.(@RequestBody TbItem tbItem)
    //前端请求 json格式的参数
    //{"title":"aadad","id":"1381937",..}
    public   R updateTbItem(TbItem tbItem){
        return  tbItemService.updateTbItem(tbItem);
    }

}
